package Numpy;

public class ArrayRemoveDuplicatedElement026 {
    public static void main(String[] args) {
        System.out.println(removeDuplicates(new int[]{0,0,1,1,1,2,2,3,3,4}));
    }
    public static int removeDuplicates(int[] nums) {
        int startIndex = 0;
        int endIndex = 0;
        for (int curIndex = 1; curIndex <= nums.length-1; curIndex++) {
            for (int i = endIndex; i >= startIndex; i--) {
                if(nums[curIndex] == nums[i]){
                    break;
                }else if(i == startIndex){
                    nums[++endIndex] = nums[curIndex];
                }
            }
        }
        return endIndex+1;
    }
}
